<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<isperp:grid url="constract/tmc/listDetail" gridId="constractGrid"
    multiselect="true" multikey="true"	ondbClickRowEvent=""
	cusEditUrl="constract/tmc/edit"
	cusViewUrl="constract/tmc/view"
	cusDeleteUrl="constract/tmc/delete">

	<jsp:attribute name="toolbar">
	<isperp:toolbar id="constractToolbar">
		<isperp:button id="constractCreate" icon="icon-plus" text="新增TMC合同"
			cssClass="nui-mainbtn" onclick="constractGrid.create();"/>
		<isperp:button id="aaa" text="导出到Excel" icon="icon-download"
			cssClass="nui-mainbtn" onclick="aaa();"/>
		<isperp:button id="aaa" text="导出封页" icon="icon-"
					   cssClass="nui-mainbtn" onclick="bbb();"/>

	</isperp:toolbar>
	</jsp:attribute>

	<jsp:attribute name="searchbar">
	<table class="search-table" id="mmm">
		<tbody>
			<tr>
				<td class="td1">编号：</td>
				<td class="td2"><input type="text" field="code" op="cn">
					</td>
				<td class="td1">标题：</td>
				<td class="td2"><input type="text" field="title" op="cn">
					</td>
				<td class="td1">分类：</td>
				<td class="td2"><input type="text" field="changeType" op="cn">
				</td>
			</tr>
			
		</tbody>
	</table>
	</jsp:attribute>
	<jsp:body>
		<table id="grid-table">
			<isperp:column name="id" title="id" hidden="true"></isperp:column>

			<isperp:column name="constract_name" title="<div style=\"text-align:center;\">合同名称</div>" align="center"></isperp:column>

			<isperp:column name="constract_status" title="<div style=\"text-align:center;\">合同状态</div>" align="center"></isperp:column>

			<isperp:column name="tc_order_id" width="100" title="<div style=\"text-align:center;\">特采单号</div>"  align="center"></isperp:column>

			<isperp:column name="constract_code" title="<div style=\"text-align:center;\">合同编号</div>" width="100" align="center"></isperp:column>

			<isperp:column name="principal" title="<div style=\"text-align:center;\">担当</div>" width="100" align="center"></isperp:column>

			<isperp:column name="constract_classify" title="<div style=\"text-align:center;\">合同分类</div>" width="100" align="center"></isperp:column>

			<isperp:column name="create_date" title="<div style=\"text-align:center;\">创建时间</div>" width="100" align="center"></isperp:column>
		</table>
	</jsp:body>
</isperp:grid>



<script type="text/javascript">

	function aaa() {
		console.log("导出到Excel");
		var ids = [];
		var selecteds = $("tr[aria-selected=true]");

		for(var i=0; i<selecteds.length; i++) {
			console.log(selecteds[i]);
			var tcOrderId = selecteds[i].children[3].getAttribute("title");
			console.log("id[" + i + "]=" + tcOrderId);
			ids.push(tcOrderId);
		}
		console.log(ids);
		var data = {
			"aaa": ids
		}
		var bbb = $.param(data, true)
		console.log('./constract/tmc/export/excel?' + bbb);
		window.location = './constract/tmc/export/excel?' + bbb;
	}

	function bbb() {
		console.log("导出封面");
		var ids = [];
		var selecteds = $("tr[aria-selected=true]");

		for(var i=0; i<selecteds.length; i++) {
			console.log(selecteds[i]);
			var tcOrderId = selecteds[i].children[3].getAttribute("title");
			console.log("id[" + i + "]=" + tcOrderId);
			ids.push(tcOrderId);
		}
		console.log(ids);
		var data = {
			"aaa": ids
		}
		var bbb = $.param(data, true)
		console.log('./constract/tmc/export/excel?' + bbb);
		window.location = './constract/tmc/export/excel?' + bbb;
	}

</script>
